from typing import Optional
from pydantic import BaseModel, Field


class ModelIDParam(BaseModel):
    model_id: int = Field(title="模型ID")


class ModelList(BaseModel):
    model_list: list = Field(title="模型列表", default=[1, 2])


class UpdateParam(BaseModel):
    model_id: int = Field(title="模型ID")
    model_name: str = Field(title="模型名")
    model_description: str = Field(title="模型描述")


class ModelTypeParam(BaseModel):
    Model_Type: int = Field(title="模型类型", default=-1)
    Sensitivity_Type: int = Field(..., title="敏感性类别")


class ModelTrainParam(BaseModel):
    model_id: int = Field(title="模型ID")
    Hidden_layers: int = Field(title="隐藏层层数", default=2)
    HideLayer_CoreNum: int = Field(title="每层隐藏神经元个数", default=2)
    HideLayer_Active: str = Field(title="激活函数类型", default='sigmoid')
    Learn_Rate: float = Field(title="学习率", default=0.1)
    Target_error: float = Field(title="目标误差", default=0.001)
    MaxEpoch: int = Field(title="最大迭代数", default=200)


class ModelNameParam(BaseModel):
    user_id: int = Field(..., title="用户")
    model_name: str = Field(..., title="模型名")
    model_type: int = Field(..., title="模型类型")
    sensitivity_type: int = Field(..., title="敏感性类别")
    model_description: str = Field(..., title="模型描述")


class ModelParamUpdate(BaseModel):
    add: list = Field(title="添加", default=[
        {'Parameter_Ecode': 1, "Parameter_Name": 2, "Parameter_UOM_Name": 3, "Model_ID": -1}])
    delete: list = Field(title="删除", default=[
        {'Model_ID': 1, "Parameter_ID": 2}])
    update: list = Field(title="修改",
                         default=[
                             {'Parameter_ID': 1, "Parameter_Ecode": '#',
                              'Parameter_Name': '#', 'Parameter_UOM_Name': '#'}])


class ModelTrainDataUpdate(BaseModel):
    add: list = Field(title="添加", default=[
        {'Core_ID': -1, "Model_ID": -1}])
    delete: list = Field(title="删除", default=[
        {'Core_ID': -1, "Model_ID": -1}])
    update: list = Field(title="修改",
                         default=[
                             {'Core_ID': 1}])
